package com.biz.hunter.dao;

import org.springframework.stereotype.Repository;

import com.biz.hunter.db.entity.Page;
import com.biz.hunter.db.entity.PlatformEnum;
import com.biz.hunter.dbutil.BaseDAO;


@Repository
public class PageDAO {
	private static final String SQL_GET = "select * from tb_page  where openId = ? and platformId = ?";
	private static final String SQL_SAVE = "insert into tb_page(openId,pageNum,platformId) values(?,?,?)  ";
	private static final String SQL_UPDATE = "update tb_page set pageNum=?  where openId = ? and platformId= ?";
	
	public Page getByOpenId(String openId, int platformId){
		return  BaseDAO.queryForObject(Page.class, SQL_GET, openId,platformId);
	}

	
	public int save(Page page) {

		return BaseDAO.execute(SQL_SAVE, page.getOpenId(),page.getPageNum(),page.getPlatformId());

	}
	
	public int update(Page page) {
		return  BaseDAO.execute(SQL_UPDATE, page.getPageNum(), page.getOpenId(),page.getPlatformId());
	}
	
	public Page getById(String id,int platformId) {
		return BaseDAO.queryForObject(Page.class, SQL_GET, id);
	}
	
}
